import React from 'react'
import { NavLink } from 'react-router-dom'
import {connect} from 'react-redux'
import {bindActionCreators} from 'redux'
import { actions as UserAction } from '../../reducers/user'

class Nav extends React.Component {
    render() {
        const { is_execute, is_manager, is_publish } = this.props.userInfo,
            _url = !(is_execute||is_manager||is_publish) ? '/role' : '/my-project/publish'
        return(
            <div className="bar-nav">
                <NavLink to='/' activeClassName="first" exact >
                    <i className="iconfont icon-shouye">首页</i>
                </NavLink>
                <NavLink to={_url} activeClassName="first"
                isActive={(match, location)=>location.pathname.indexOf('my-project/')!=-1}>
                    <i className="iconfont icon-xiangmu">项目</i>
                </NavLink>
                <NavLink to='/search' activeClassName="first">
                    <i className="iconfont icon-sousuo">搜索</i>
                </NavLink>
                <NavLink to='/personal' activeClassName="first">
                    <i className="iconfont icon-wode">我的</i>
                </NavLink>
            </div>
        )
    }
}

function mapStateToProps(state) {
    return {
      userInfo: state.user.userInfo,
    }
}
  
function mapDispatchToProps(dispatch) {
    return  {
    }
}
  
export default connect(
    mapStateToProps,
    mapDispatchToProps
)(Nav)